package com.jjb.www.ui.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;

import com.hjq.shape.layout.ShapeRelativeLayout;
import com.hjq.shape.view.ShapeImageView;
import com.hjq.shape.view.ShapeTextView;
import com.jjb.www.R;
import com.jjb.www.app.AppAdapter;
import com.jjb.www.http.api.ExamMessageApi;

/**
 *    author : Android CRG
 *    github : https://github.com/getActivity/AndroidProject
 *    time   : 2018/11/05
 *    desc   : 可进行拷贝的副本
 */
public final class AnswerSheetAdapter extends AppAdapter<ExamMessageApi.Bean.FillListDTO.NumberListDTO> {

    public AnswerSheetAdapter(Context context) {
        super(context);
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder();
    }

    private final class ViewHolder extends AppAdapter<?>.ViewHolder {
        private ShapeRelativeLayout mLlItem;
        private ShapeTextView mTvContent;
        private ShapeImageView mImgType;



        private ViewHolder() {
            super(R.layout.item_answer_sheet);
            mLlItem = findViewById(R.id.ll_item);
            mTvContent = findViewById(R.id.tv_content);
            mImgType = findViewById(R.id.img_type);
        }

        @Override
        public void onBindView(int position) {
            ExamMessageApi.Bean.FillListDTO.NumberListDTO bean = getItem(position);
            mTvContent.setText(bean.getOrder_number()+"");
            if (bean.getIs_sign()==1){
                //已标记
                mImgType.setVisibility(View.VISIBLE);
            }else {
                mImgType.setVisibility(View.GONE);
            }
            if (bean.getIs_answer()==1){
                //已答题
                mLlItem.getShapeDrawableBuilder()
                        .setSolidColor(ContextCompat.getColor(getContext(), R.color.color_EAF1FE))
                        .setStrokeColor(ContextCompat.getColor(getContext(), R.color.color_3675FE))
                        .setStrokeWidth(1)
                        .intoBackground();
            }else {
                mLlItem.getShapeDrawableBuilder()
                        .setSolidColor(ContextCompat.getColor(getContext(), R.color.white))
                        .setStrokeColor(ContextCompat.getColor(getContext(), R.color.color_B1B1B1))
                        .setStrokeWidth(1)
                        .intoBackground();
            }
        }
    }
}